<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */
$ie=false;
if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE"))$ie=true;
?>
<?php if(!$ie):?>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.imgareaselect/scripts/jquery.imgareaselect.pack.js"></script>
<link rel='stylesheet' type='text/css' href='<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.imgareaselect/css/imgareaselect-default.css'>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.imgareaselect/index.js"></script>
<?php endif;?>
<div class="title">
	<h3>照片管理--上传</h3>
	<ul>
		<li class="current"><?php echo CHtml::link('照片管理', array('pic/index'));?></li>
		<li><?php echo CHtml::link('日志管理', array('post/index'));?></li>
	</ul>
</div>

<div class="main_content">
    <style type="text/css">
	.errorMessage{ padding-left:60px; color:#f00}
	</style>
	<?php echo CHtml::beginForm('','post',array('enctype' => 'multipart/form-data','name'=>'form1','id'=>'form1'));?>
	<?php echo CHtml::activeHiddenField($model,'upload',array('value' =>1))?>
	<div class="single_upload">
		<div class="add_photo"> <span class="left">添加图片:</span> 
			<span class="single_upload_select">选择图片上传
			<?php echo CHtml::activeFileField($model,'picpath',array('id'=>'picpath'));?>
		</span> 
		<?php echo $msg['desc'];?>
		<?php echo CHtml::error($model,'picpath');?>
		<?php echo CHtml::error($model,'title');?>
		</div>
		<div class="show_photo">
			<div class="show_pic" id="image_area"><?php if(!$ie):?><img id='biuuu' src=""><?php endif;?></div>
		</div>
		<div class="upload_photo_infor"> <span class="left">图片说明:</span>
			<?php echo CHtml::activeTextField($model,'title');?>

			<span class="upload_ctrl_s" >保存</span> </div>
			<div class="batch_upload_to"> 
		<!-- <a href="<?php echo CHtml::normalizeUrl(array('pic/mult'));?>" title="批量选择图片上传">批量选择图片上传</a> 
				<p>提示：每次最多可以批量上传10张照片，按”Ctrl”键可以一次选择多张照片</p> -->
			</div>
		</div>
	<?php echo CHtml::endForm();?>
	</div>
<script type="text/javascript">
var msg = "<?php echo $msg['status'];?>";
var status = 0;
$(document).ready(function(){
	$('#picpath').change(function(){
		var str = $(this).val().toLowerCase().split('.');
		var type =str[str.length-1];

		if(type=='png'||type=='jpg'||type=='jpeg'||type=='gif'||type=='bmp'){
			<?php if($ie):?>
			utils.PreviewImg($('#picpath').get(0));
			<?php endif;?>
			status = 1;
		}else{
			status = 0;
			$('#picpath').val('');
			alert("只能选择图片");
		}
	})
	$('.upload_ctrl_s').click(function(){
		if(status!=0){
			$('#form1').submit();
		}else{alert("只能选择图片");}

	});

if(msg=='0'){
	// $('#topmsg').html("<?php echo $msg['desc']; ?>");
 //    $('#showmsg').show();
 //    showDialog();
    //setTimeout(function(){location.reload();},300);

}

})
</script>
